package com.tcenter.dao.entities;


import javax.persistence.*;
import java.util.Date;

/**
 *
 */
@Entity
@Table(name = "student_task", catalog = "tcenterdb")
public class StudentTask implements java.io.Serializable {

    private StudentTaskId id;
    private Student student;
    private Task task;
    private Date date;


    public StudentTask() {
    }

    public StudentTask(StudentTaskId id, Student student, Task task) {
        this.id = id;
        this.student = student;
        this.task = task;
    }

    public StudentTask(StudentTaskId id, Student student, Task task, Date date) {
        this.id = id;
        this.student = student;
        this.task = task;
        this.date = date;
    }


    @EmbeddedId
    @AttributeOverrides({
            @AttributeOverride(name = "studentId", column = @Column(name = "student_id", nullable = false)),
            @AttributeOverride(name = "taskId", column = @Column(name = "task_id", nullable = false))})
    public StudentTaskId getId() {
        return this.id;
    }

    public void setId(StudentTaskId id) {
        this.id = id;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "student_id", nullable = false, insertable = false, updatable = false)
    public Student getStudent() {
        return this.student;
    }

    public void setStudent(Student student) {
        this.student = student;
    }

    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn(name = "task_id", nullable = false, insertable = false, updatable = false)
    public Task getTask() {
        return this.task;
    }

    public void setTask(Task task) {
        this.task = task;
    }

    @Temporal(TemporalType.TIMESTAMP)
    @Column(name = "date", length = 19)
    public Date getDate() {
        return this.date;
    }

    public void setDate(Date date) {
        this.date = date;
    }

}
